package commands;

import indexes.BattingIndex;
import indexes.PlayerIDIndex;
import indexes.PlayerNameIndex;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

import util.BattingDatabaseFile;
import util.DatabaseFile;
import util.PlayerLogger;

import main.PlayerDB;
/**
 * This shows the index for either a player id 
 * or a player name.
 * @author bfults (Brian Fults - 905084698)
 *
 */
public class ShowIndexForCommand extends Command
{
    /**
     * Typical constructor.
     * @param args
     */
    public ShowIndexForCommand(List<String> args)
    {
        super(args);
    }
    
    

    @Override
    public boolean execute(
        PlayerIDIndex idIndex,
        PlayerNameIndex nameIndex,
        PlayerLogger logger,
        DatabaseFile database, BattingIndex battingIndex, BattingDatabaseFile battingDatabase ) throws IOException
    {
        logger.write(super.getDivider() + "\n");
        logger.write("Command: show_index_for " + getArguments().get(0) + "\n\n");
        String indexName = getArguments().get(0); 
        if (indexName.equals("PlayerID"))
        {
            idIndex.logIndex();
        }
        else if (indexName.equals("PlayerName"))
        {
            nameIndex.logIndex();
        }
        else if (indexName.equals("Batting"))
        {
            battingIndex.logIndex();
        }
        else
        {
            logger.write("Unknown index name: " + indexName + "\n");
        }
        return true;
    }
    
   


}
